<template>
<view class="a">
    <!-- #ifndef MP-WEIXIN  -->

    <!-- #endif -->
    <home class="aa" :notice="notice"  v-if="cur==0"></home>
    <tools class="aa" :navList="navList" v-if="cur==1"></tools>
    <me class="aa" v-if="cur==2"></me>
    <loading v-if="!isShow"></loading>
    <!-- <view @click="login=!login">登陆陆</view> -->
    <login v-if="!login"></login>
    <!-- <official-account   @bindload="bindload()" @binderror="binderror()"></official-account> -->
    <view class="bu" :class="is_ipX?'foot_bottom':''"></view>
    <view class="footer row" :class="is_ipX?'foot_bottom':''">
        <view class="col" v-for="(item,index) in tabBar.list" :key="index" @click="go(item.pagePath,index)">
            <!-- <image class="icon" :src="cur==index?item.selectedIconPath:item.iconPath" mode="" /> -->
			<view class="icon" :class="cur==index?item.selectedIconPath:item.iconPath"></view>
            <view class="text" :class="cur==index?'cur':''">{{item.text}}</view>
            <!-- <ipx></ipx> -->
        </view>
	</view>
    
</view>

</template>
<script>
    import home from './homePage'
    import me from './mePage'
    import tools from './tools'
	export default {
        components:{
            home,me,tools
        },
		data() {
			return {
                cur:0,
                login:true,
				tabBar: {
                    color: "#999999",
                    selectedColor: "#ff4a4a",
                    list: [
                        {
                            pagePath: "cuIcon-home",
                            text: "首页",
                            iconPath: "cuIcon-home",
                            selectedIconPath: "cuIcon-homefill cur"
                        },
                        {
                            pagePath: "cuIcon-home",
                            text: "工具箱",
                            iconPath: "cuIcon-tag",
                            selectedIconPath: "cuIcon-tagfill cur"
                        },
                        {
                            text: "我的",
                            iconPath: "cuIcon-my",
                            selectedIconPath: "cuIcon-myfill cur"
                        }
                    ]
                },
                navList:[],
                notice:{},
                isShow:false,
                is_ipX:false
			};
		},
       
        async onLoad(opt){
            if (opt.scene) {
            let url="/"+decodeURIComponent(opt.scene)
                uni.navigateTo({
                    url,
                    success:res=>{
                        console.log(res);
                    },
                    fail:(err)=>{
                        console.log(err);
                        uni.$err(err.errMsg)
                    }
                }); 
                // uni.reLaunch({
                //      url
                // });
            }
            this.initData()
            // let url='/videoLogo/pages/details?isHome=1'
            // uni.navigateTo({
            //     url
            // });
            this.is_ipX=getApp().is_ipX

        },
        onShareAppMessage(){

        },
		methods: {
            async initData(){
                let res =await uni.$request({},
                "api/applet/initdata")
                if (res.code==200) {
                    this.navList=res.data.navList
                    this.notice=res.data.notice
                    this.isShow=true
                }else{
                    uni.$err(res.msg)
                }
            },
			go(url,index){
                let is_avatar=uni.getStorageSync('user_info').avatarUrl
                is_avatar="acscs"
                if (index==1&&!is_avatar) {
                    uni.navigateTo({
                        url: '/tools/login/login'
                    });
                }else{
                    this.cur=index
                }
                
            },
            bindload(e){
                console.log(e);
            },
            binderror(e){
                console.log(e);
            }
		}
	}
</script>

<style lang="scss">
    $col:$main_col;
    .bu{
        height: 100rpx;
    }
    .footer{
        width: 100%;
        height: 100rpx;
        position: fixed;
        bottom: 0rpx;
        background: #fff;
        // justify-content: space-evenly;
        box-shadow: 0rpx 0rpx 10rpx 10rpx #e1e1e1;
       justify-content: space-around;
        .icon{
            // width: 50rpx;
            // height: 50rpx;
            font-size: 50rpx;
        }
        .cur{
            color: $col;
        }
    }
</style>